package algo.LocalSearch;

import algo.Model.VarInt;

public class VarIntLS extends VarInt {
	//LocalSolver	_ls;
	/**
	 * @param args
	 */
	int	_oldValue;
	
	public VarIntLS(LocalSolver ls, int min, int max){
		super(min,max);
		//_ls = ls;
		setLocalSolver(ls);
		ls.post(this);
		//System.out.println("VarIntLS::constructor --> OK");
	}
	public int getOldValue(){
		return _oldValue;
	}
	public void setValuePropagate(int val){
		_oldValue = getValue();
		super.setValue(val);
		getLocalSolver().propagateInt(this, val);
	}
	public String name(){
		return "VarIntLS[" + getID() + "]";
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("Test VarIntLS");
		LocalSolver ls = new LocalSolver();
		VarIntLS x = new VarIntLS(ls,1,5);
		VarIntLS y = new VarIntLS(ls,1,5);
		
		IFunction f = new FuncPlus(x,y);
		IFunction g = new FuncPlus(x,y);
		IFunction k = new FuncPlus(f,g);
		IFunction h = new FuncPlus(g,k);
		ls.close();
		System.out.println("-----------------------close--------------------");
		ls.println();
		
		x.setValuePropagate(2);
		y.setValuePropagate(4);		
		System.out.println("f = " + f.getValue() + " k = " + k.getValue() + " h = " + h.getValue());

		x.setValuePropagate(8);		
		System.out.println("f = " + f.getValue() + " k = " + k.getValue() + " h = " + h.getValue());

	}																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																										

}
